All Questions
Tagged with functional-programmingobject-oriented
34 questions
3votes
1answer
104views
Sequentially find the indexes of an element into a collection
Util class to find into a collection the indexes of a given element with multiple occurrences from the first index or relative to a given index. ...
1vote
1answer
140views
Transform an array into object and set index for an unique key in javascript
I have a method that merges keys and indexes from an array into an object. I'm stuck with ways to compress this method, and I don't know what I can do to make it simpler. Goal get an array of objects ...
3votes
0answers
75views
A Haskell-style "maybe" type in Python, version 2
I have decided on a preferred solution to my question A maybe type in Python. Which implementation is best?, and have expanded it to be more ergonomic. I have implemented a host of utility functions (...
3votes
2answers
742views
MP3 Playlist Class in Python
Background Info I am an intermediate level Python programmer. This is my implementation of a MP3 Playlist class challenge that was hosted on 101 Computing.Net. The ...
0votes
1answer
239views
Refactoring this code into OOP & less functional programming
I got feedback from an interview test where they wanted me to prove that I've got a grasp of OOP php programming. This file especially I got feedback on that it's more functional than it is Object-...
10votes
3answers
764views
JavaScript OOD: 2048
I wrote a 2048 game in JavaScript with an object-oriented paradigm. The game board is presented with a two-dimensional array and each tile holds an integer. Here is the implementation: ...
1vote
1answer
105views
JavaScript, looping, and functional approach
Data Structure coming back from the server ...
1vote
1answer
53views
-2votes
1answer
63views
python - class not returning the expected result. I am using function and a class [closed]
I am trying to pass 2 values from a function to the class and get a result from the class. For example, if I send value "dog" I should get the result as "dog runs" as a returned result. Need help with ...
0votes
1answer
78views
Functional vs Object Oriented Approach for UI codes
I have the following snippets. which formats error messages based on a map. I can do it as a simple function call the function for transforming the error. or create a class and handle it in that way. ...
2votes
0answers
66views
Immutable-Object-like Structure in PHP
I made a closure-based PHP structure that behaves mostly like a classical object. To change the object's state, one must derive a new copy by passing the altered state to the ...
2votes
1answer
554views
Constructor function for persons with hobbies
I'm trying to write a constructor function that generates instances of a user. One of the properties of the user class is an array of the user's hobbies. I'd like ...
15votes
2answers
2kviews
Message-formatting code with pluralization, revised to be more functional
I'm a C++ dev, and I've recently started working my way through Clean Code*. Whenever I encounter an example I think I could improve, I try to re-implement it in C++. On pp. 28-29 there is an example ...
2votes
0answers
54views
Dispatch different parameters to different classes with single interface [closed]
I have a set of classes that have similar funcionality but very different interfaces. I created two interface classes with polymorphic methods so I can operate over then. When creating calling the ...
1vote
1answer
943views
Graph implementation in C++ using adjacency list
there is my final code for implementing a Graph in C++ using adjacency list and Object-oriented. I got some help from StackOverflow and it was really helpful, but now I would ask about some advice for ...